import request from '@/utils/request'

const baseRequest = (path: string) => `/api/post/${path}`

export const postAddService = (post: any) =>
    request.post(baseRequest('add'), post)

export const getAllPostsService = () =>
    request.get(baseRequest('all'))


export const getPage = (page_number: number, page_size: number, username: any = null) =>
    request.get(baseRequest('page'), {
        params: { page_number, page_size, username }
    })

export const updatePostService = (post: any) => request.put(baseRequest('update'), post)

export const delPostService = (id: string) => request.delete(baseRequest(`del/${id}`))